using System;
using System.Collections.Generic;
using System.Web;
using CSI.Directory.Core.Model;
using CSI.Directory.Core.Services;

namespace C3.Directory.Services
{
    

    public class CacheManager : ICacheManager
    {
        private IList<Category> categories;
        private const string CategoryKey = "Categories";
        private const string CountyKey = "Counties";

        public void Cache(IList<Category> category)
        {
            HttpContext.Current.Cache.Remove(CategoryKey);
            HttpContext.Current.Cache.Insert(CategoryKey, category);
        }

   

        public IList<Category> Categories
        {
            get { 
                return HttpContext.Current.Cache[CategoryKey] as IList<Category>; 
            }
            set { throw new NotImplementedException(); }
        }

        public IList<County> Counties
        {
            get
            {
                return HttpContext.Current.Cache[CountyKey] as IList<County>;
            }
            set { throw new NotImplementedException(); }
        }

        public void Cache(List<County> counties)
        {
            HttpContext.Current.Cache.Remove(CountyKey);
            HttpContext.Current.Cache.Insert(CountyKey, counties);
        }

        public void Clear()
        {
            foreach (System.Collections.DictionaryEntry entry in HttpContext.Current.Cache)
            {


                HttpContext.Current.Cache.Remove(entry.Key.ToString());


            }

        }
    }
}